$("input[name='code_way']").change(function(){
	var code_way = $("input[name='code_way']:checked").val();
	if(code_way=='phone'){
		$("#li_code_way_tool").html('手机号：&nbsp;&nbsp;&nbsp;&nbsp;');
	}	
	if(code_way=='email'){
		$("#li_code_way_tool").html('邮箱Email：&nbsp;&nbsp;&nbsp;&nbsp;');
	}	
})

var send_code_info = new Object();
send_code_info.response=function(res){
	if(res.success=='success'){
		alert('发送成功,请注意查收');
	}
	if(res.success=='fail_phone_user'){
		alert('系统无此手机号,请重新输入');
	}
	if(res.success=='fail_mail_user'){
		alert('系统无此邮箱,请重新输入');
	}
}
$("#send_code").click(function(){
	var code_way =  $("input[name='code_way']:checked").val();
	var code_way_tool = $("#code_way_tool").val();
	if(code_way=='email'){
		if(code_way_tool==""){
			alert('请填写正确的邮箱');
			return;
		}
		var postJsondata = {"email":code_way_tool};
		$.ajax({
			 type:'POST',
			 url:'sendVerification.html',
			 data:postJsondata,
			 dataType: 'json',
			 success:send_code_info.response,
			 async:false
		});			
	}
	if(code_way=='phone'){
		if(code_way_tool==""){
			alert('请填写正确的手机号码');
			return;
		}		
		
		var postJsondata = {"phone":code_way_tool};
		$.ajax({
			 type:'POST',
			 url:'sendCode.html',
			 data:postJsondata,
			 dataType: 'json',
			 success:send_code_info.response,
			 async:false
		});			
	}
	
})

var update_pass_info = new Object();
update_pass_info.response = function(res){
	if(res.success=='success'){
		alert('密码重置成功');
	}	
	if(res.success=='fail_code_info'){
		alert('验证信息过期,请重新获取验证码');
	}	
	if(res.success=='fail_code'){
		alert('验证码错误,请重新输入');
	}	
	if(res.success=='fail_user'){
		alert('系统无此人信息,请核实录入信息');
	}	
	if(res.success=='fail'){
		alert('密码重置更新失败');
	}	
}

$("#update_pass").click(function(){
	var code_way = $("input[name='code_way']:checked").val();
	var code = $("#code").val();
	var code_way_tool = $("#code_way_tool").val();
	var password = $("#reset_password").val();
	var confirm_password = $("#reset_confirm_password").val();
	if(password!=confirm_password){
		alert('请保持确认新密码与新密码一致');
		return;
	}
	
	var postJsondata = {"code_way":code_way,"code":code,"code_way_tool":code_way_tool,"password":password,"confirm_password":confirm_password};
	$.ajax({
		 type:'POST',
		 url:'updateForgotPassword.html',
		 data:postJsondata,
		 dataType: 'json',
		 success:update_pass_info.response,
		 async:false
	});		
})